% To execute after 'exercise_7.m' for including measurement data in figure 4.
%
% The pressure at natural focus for low pressure (i.e. linear propagation)
% is 21.28kPa.
load('.\measurement\wave_5V_at_focus.mat')
max(abs(hilbert(rf)))
% To match this with the simulation we need a source pressure of
% approximately 10.5kPa. Multiplying this by 16/5=3.2 we have the source
% pressure for the 'high' pressure measurements.

figure(4)
hold on
load('.\measurement\scan_at_90mm.mat')

x=-15:0.5:15;
N_r=length(x);
N_DownSample=10;

f_Sample=round(1/sc.scan.data.Ts(1)/1000)*1000/N_DownSample;
P_Filt=zeros(3, N_r);
for i=1:3
  [B, A]=butter(FiltOrd, ((FiltBW + i)*f_0)/(f_Sample/2));
  DummyMat=filter(B, A, mean(reshape(sc.scan.data.Pressure.rf, N_DownSample, 10000/N_DownSample, 61)));
  P_Filt(i, :)=20*log10(max(abs(hilbert(DummyMat))));
  h_3(3)=plot(x, P_Filt(i, :), 'b--', 'LineWidth', 1);
end
legend([h_3(2) h_3(3)] , {'simulated', 'measured'})